using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.SessionState;
using Common;
using Net.SourceForge.WURFL.Core;

namespace Roaming
{
    public class Global : System.Web.HttpApplication
    {

        private const string WURFL_MANAGER = "Net.SouceForge.WURFL.WURFLMANAGER";
        public Global()
        {
        }

        void Application_Start(object sender, EventArgs e)
        {
            //IWURFLManagerProvider<IWURFLManager> wurflManagerProvider = new WURFLManagerProvider();
            //new WURFLManagerHolder(wurflManagerProvider.WURFLManager);
            //Application[WURFL_MANAGER] = wurflManagerProvider.WURFLManager;
            //log4net.Config.XmlConfigurator.Configure();
            Application["CurrentUsers"] = 0;
        }

        void Application_End(object sender, EventArgs e)
        {
            //  Code that runs on application shutdown

        }

        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs
        }

        void Session_Start(object sender, EventArgs e)
        {
            // Code that runs when a new session is started
            // Code that runs when a new session is started
            Session.Timeout = 20;
            //Session["Start"] = "Now";
            Application.Lock();
            Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) + 1;
            Application.UnLock();

        }

        void Session_End(object sender, EventArgs e)
        {
            Application.Lock();
            Application["CurrentUsers"] = System.Convert.ToInt32(Application["CurrentUsers"]) - 1;
            Application.UnLock();
        }

    }
}